﻿using System;

using System.Collections.Generic;
using System.Text;
using ScannerApp.Utils;
using System.Collections;

namespace ScannerApp.ScannerWebserviceWrapper
{
    public class BindingQRResult : BaseOrderResult
    {
        public List<MergedBindingQRProductInfo> batStockInfoList;
        public List<QRStockInfo> qrStockInfoList;

        public int orderTotalPage;
        public int orderTotalCount;
        private int orderPageIndex;
        private int scanTotalPage;
        private int scanTotalCount;
        private int scanPageIndex;

        public int OrderPageIndex
        {
            get { return orderPageIndex; }
            set { orderPageIndex = value; }
        }

        public int ScanPageIndex
        {
            get { return scanPageIndex; }
            set { scanPageIndex = value; }
        }

        public int ScanTotalPage
        {
            get { return scanTotalPage; }
            set { scanTotalPage = value; }
        }

        public int ScanTotalCount
        {
            get { return scanTotalCount; }
            set { scanTotalCount = value; }
        }

        public int OrderTotalPage
        {
            get { return orderTotalPage; }
            set { orderTotalPage = value; }
        }

        public int OrderTotalCount
        {
            get { return orderTotalCount; }
            set { orderTotalCount = value; }
        }

        public bool IsRepeatedScan(string barcode)
        {
            if (this.qrStockInfoList != null)
            {
                foreach (QRStockInfo rec in this.qrStockInfoList)
                {
                    if (rec.serialNumber.Equals(barcode))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        #region IScanProduct 成员
        public override bool IsProductCodeInOrder(string productCode)
        {
            foreach (MergedBindingQRProductInfo rec in this.batStockInfoList)
            {
                if (rec.productcode.Equals(productCode))
                {
                    return true;
                }
            }
            return false;
        }


        public override bool IsProductEnablingQR(string productCode)
        {
            return true;
        }

        #endregion


    }



    public class MergedBindingQRProductInfo
    {

        [DataTableFieldAttribute(HeaderText = "产品代码")]
        public String productcode; //产品代码

        [DataTableFieldAttribute(HeaderText = "批次")]
        public String batchnumber; //批次

        [DataTableFieldAttribute(HeaderText = "货位号")]
        public String positioncode; //货位编号

        public String positionname; //货位名称

        public String productname; //产品名称

        public String cPlid; //产品线

        public String warehouseName; //仓库名称

        public String validat; //有效期

        //[DataTableFieldAttribute(HeaderText = "可用量")]
        public float usequantity; //可用量

        [DataTableFieldAttribute(HeaderText = "现存量")]
        public float existsquantity; //现存量

        [DataTableFieldAttribute(HeaderText = "已绑定数量")]
        public float bindingamt; //已绑定数量

        public bool isDeleted;
    }

}
